var leftBtn = document.querySelector(".zizhi_left")
var rightBtn = document.querySelector(".zizhi_right")
var oul = document.querySelector(".zizhi_ul")
var a = oul.offsetLeft

if (a > -1) {
    add(leftBtn, "default", "zizhi_left", "zizhi_left1")
}
if (a < -1779) {
    add(rightBtn, "default", "zizhi_right", "zizhi_right1")
}

leftBtn.addEventListener("click", leftMove, false)
rightBtn.addEventListener("click", rightMove, false)


function leftMove() {
    if (a > -1) {
        add(leftBtn, "default", "zizhi_left", "zizhi_left1")
        oul.style.left = "0"
    } else {
        remove(leftBtn, "pointer", "zizhi_left1", "zizhi_left")
        a += 890
        oul.style.left = a + "px"
        if (a > -1) {
            add(leftBtn, "default", "zizhi_left", "zizhi_left1")
            remove(rightBtn, "pointer", "zizhi_right1", "zizhi_right")
        }
    }
}
function rightMove() {
    if (a < -1779) {
        add(rightBtn, "default", "zizhi_right", "zizhi_right1")
        oul.style.left = "-1780px"
    } else {
        remove(rightBtn, "pointer", "zizhi_right1", "zizhi_right")
        a -= 890
        oul.style.left = a + "px"
        if (a < -1779) {
            add(rightBtn, "default", "zizhi_right", "zizhi_right1")
            remove(leftBtn, "pointer", "zizhi_left1", "zizhi_left")
        }
    }
}

function add(ev, cursor, class1, class2) {
    ev.style.cursor = cursor
    ev.classList.remove(class1)
    ev.classList.add(class2)
}
function remove(ev, cursor, class1, class2) {
    ev.style.cursor = cursor
    ev.classList.remove(class1)
    ev.classList.add(class2)
}